package br.com.lambdacore.validator.impl;

import java.util.Collection;
import java.util.Map;

public abstract class ValidatorImpl<T> {

	private T object;

	public ValidatorImpl(T object) {
		this.setObject(object);
	}

	@Override
	public boolean equals(Object other) {
		return this.getClass().equals(other.getClass());
	}

	@Override
	public int hashCode() {
		return this.getClass().hashCode();
	}

	@Override
	public String toString() {
		return getClass().getName();
	}

	public boolean equalThan(T object) {
		return EqualValidator.is(this.getObject()).equalThan(object);
	}

	public boolean instanceOf(Class<?> clazz) {
		return ClassValidator.is(this.getObject().getClass()).instanceOf(clazz);
	}

	public boolean nil() {
		return NullValidator.is(this.getObject()).nil();
	}

	public boolean notEqualThan(T object) {
		return EqualValidator.is(this.getObject()).notEqualThan(object);
	}

	public boolean notInstanceOf(Class<?> clazz) {
		return ClassValidator.is(this.getObject().getClass()).notInstanceOf(
				clazz);
	}

	public boolean notNil() {
		return NullValidator.is(this.getObject()).notNil();
	}

	protected T getObject() {
		return this.object;
	}

	private void setObject(T object) {
		this.object = object;
	}

	public static ClassValidator is(Class<?> object) {
		return ClassValidator.is(object);
	}

	public static CollectionValidator is(Collection<?> collection) {
		return CollectionValidator.is(collection);
	}

	public static MapValidator is(Map<?, ?> map) {
		return MapValidator.is(map);
	}

	public static NumberValidator is(Number number) {
		return NumberValidator.is(number);
	}

	public static ObjectValidator is(Object object) {
		return ObjectValidator.is(object);
	}

	public static ArrayValidator is(Object[] objects) {
		return ArrayValidator.is(objects);
	}

	public static StringValidator is(String string) {
		return StringValidator.is(string);
	}

}
